package com.chap14;

/**
 * Created by IntelliJ IDEA.
 * User: bj910
 * Date:2023-04-13
 * Time: 4:55
 * To change this template use File | Settings | File Templates.
 */
public class AtomicTest3 {
    private static volatile int counter = 0;

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                for (int j = 0; j < 10000; j++) {
                    counter++;
                }
            }).start();

        }

        Thread.sleep(3000);

        System.out.println(counter);
    }
}
